<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p>使用parentNode获取父节点</p>
    <div class="div">
        <p id="p1">p1</p>
    </div>
    <button onclick="findParent()">获取父节点</button>
    <script>

        let p = document.querySelector("#p1");
        let div = document.querySelector(".div");

        function findParent() {
            let node = p.parentNode;
            console.log(node.nodeName);
            console.log(div == node); // true
        }
    </script>
</body>
</html>